
settings={
    getItems : $('.sliderTh ul > li').size(),
    getWidthItems : $('.sliderTh ul li').outerWidth(),
    slidesn:3
}

$(function(){
    /*********************************/
    global.init();
    ourWork.init();
    ourWork.showProject();
    ourWork.displayProjectBox();
    ourWork.initMiniSlider();
    home.initSlider();
    home.addClassToAnimate();
	
	
	
	
	
	
	
	
	
	
/*********************************/
});


//class containing global functions
global={
    init:function(){
		
        $("#zoomImg, #team-members li a,.contact-us a.generic-btn, #contact").colorbox({
            href:$(this).attr('href'), 
            rel: $(this).attr('rel'),
            scrolling:false
        });
    }
}
//end of our global class





//this class contains functions from our_work.html page
ourWork={
    //zooming functionality
	
    init:function(){
        var setWidthNav =(parseInt([(settings.getItems*15)-15]) + parseInt((settings.getItems*settings.getWidthItems)));
        
       
        //if(settings.getItems > 4) $('a.next').show();
        $('.sliderTh ul').css('width', setWidthNav+'px');
        
        ourWork.initMiniSlider();
        
        
        
        
        
        
        
    },
	
    showProject: function(){
        $('.active .sliderTh li a').live('click', function(){
            var getId = $(this).attr('href').replace("#", "");
            var getImg = $(this).find('img').attr('src').replace("-s", "");
            var getLinkProject = $(this).attr('rel');
            $('.active #zoomImg').attr('href',getImg);
            $('.active #viewDemo').attr('href',getLinkProject);
            $('.active #slideImagesPr ul > li').removeClass('active');
            $('.active #slideImagesPr ul li#'+getId).addClass('active');
            return false;
        });
		
			
    },
	
    displayProjectBox: function(){
        $('#categories a.generic-btn').live('click', function(){
			
            var n=$(this).index();
            var x=settings.getItems=$('.sliderTh ul > li').size();
            var index=$(this).closest('article').index();
            //var getTitle = $(this).attr('title');
            var articleSelected;
            var miniSliderContainer = $('.content-center');
            var setMarginTop;
            var activeIndex=$('#showDetail article.active').index();
	    
            if(index==activeIndex){
                return false;
                //do nothing if the project is already selected.
            }
            $('#showDetail article, #categories > article').removeClass('active');
            
            $(this).parent().addClass('active');
		
              
            switch(index)
            {
                case 0:
                  
                    articleSelected = 'article#website';
                    setMarginTop = '0px';
					

                    break;
                
                case 1:
                    articleSelected = 'article#emails';
                    setMarginTop = '-247px';
				
                    
					 
                    break;
					
                case 2:
                    articleSelected = 'article#widgets';
                    setMarginTop = '-493px';
				 
                    
					 
                    break;
					
                default:
                    break;
					  
            }
			
            if(miniSliderContainer.is('.closed')){
                miniSliderContainer.removeClass('closed');		
                $(".content-center").animate({
                    height: "307px",
                    opacity:1
                }, 1000, function(){
                    $('#showDetail article').removeClass('hide');
                    $('#showDetail article').animate({
                  
                        }, 500, function(){
	                       
                            $("#contentArticle").css('margin-top',setMarginTop);
                       
                            $(articleSelected).addClass('active');
	  						 
                        });
	                       
	  						 
                });
            }else{
                $("#contentArticle").animate({
                    "marginTop": setMarginTop
                }, 1000, function(){
	                       
                    $(articleSelected).addClass('active');
	  						 
                });
				
            }
            
            
            
            
            
		
            return false;
            
            
            
            
        });
			
    },
		
		
    //initializes the minislider in our work page
    initMiniSlider: function(){
        
        var articles=$('#contentArticle > article');
        
        articles.each(
         function(){
            var miniSlides=  $('.sliderTh li',this).length;

            if(miniSlides>3){
                $('.next',this).show();   
            }   
         }
        );
        
        $('article.active #slider > a').live('click', function(e){
            e.preventDefault();

            var getDirection = $(this).attr('class');
            var getPositionFirst = $(".sliderTh ul > li:first").position().left;
            var getPositionLast = $(".sliderTh ul > li:last").position().left;
           
            switch(getDirection)
            {
                case 'prev':
					
                    $("article.active .sliderTh ul").animate({
                        "marginLeft": "+=87px"
                    }, 200, function(){
                        if(getPositionFirst != -82){
                            $('article.active a.prev').hide();
                            $('article.active a.next').show();
                        }else{
                            $('article.active a.next').show();
                            $('article.active a.prev').hide();
                        }
						 
                    });
					 
                    break;
                case 'next':
					  
                    $("article.active .sliderTh ul").animate({
                        "marginLeft": "-=87px"
                    }, 200, function(){
                        if(getPositionLast != 338){
                            $('article.active a.prev').show();
                            $('article.active a.next').hide();
                        }else{
                            $('article.active a.next').hide();
                            $('article.active a.prev').show();
                        }
                    });
						 
                    break;
                default:
                    break;
					  
            }
				
            return false;
	
        });
    }
	
}
//end of our work class
 
 
ourTeam = {
	 
    getInfoResource : function(){
	
        var paramUrl;
		
        $('team-members li a').live('click', function(event){
       
            event.preventDefault();
            paramUrl = $(this).attr('href');
        });
		
    } 
	 
	 
	 
}



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
//start new class
 
 
home={
    initSlider: function(){
         
        $('#right,#left').click(function(){
             
            home.changeSlide($(this));
             
        });
         
    },
	
    addClassToAnimate: function(){
         
        $('.contact-us').mouseenter(function(){
             
            $('.be-bosz').addClass('active');
        }).mouseleave(function(){
            $('.be-bosz').removeClass('active');
        });
         
    },
     
     
    changeSlide: function (clickedElement) {

          
           
        var slides = $('.slide');
        var animating = (slides.filter(':animated').length > 0) ? true : false;
        
        
        var active = slides.filter('.active');
        var index = active.index();
        if (!animating && (index!=clickedElement.index() || clickedElement.is('.arrow')) ) {
            
            // if((clickedElement.is('#left')&&index+1<settings.slidesn)||(clickedElement.is('#right')&&index!=0)){avoid
            // the loop
          
            if (index + 1 == settings.slidesn) {
                index = -1;
            }
			
            var next = $('.slide').eq(index + 1);
            var prev = $('.slide').eq(index - 1);
            var nextSlide ;
            var from;
      
            if (clickedElement.is('#right')) {
                nextSlide = next;
                nextSlide.removeClass('right');
                nextSlide.addClass('left');
                from = 'left';
            }
            
            
            if (clickedElement.is('#left')) {
                nextSlide = prev;
                nextSlide.removeClass('left');
                nextSlide.addClass('right');
                from = 'right';
            }
			
             $('#sliderControls li').removeClass('active').eq(nextSlide.index()).addClass('active');

            
            active.animate({
                top:-450
            },900,function(){
                nextSlide.addClass('active');
                active.removeClass('active');// active before animation
                
                
            });  
            // setTrackingTag(nextSlide.index());
       
            nextSlide.animate( {
                left : 0
            }, 1100, function() {
                active.removeAttr('style').addClass(from);
            }).removeClass(from);

            
        }
          
          

 

    }
    
    
    
     
     
     
     
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
//start new class x
 
 
 
 
 
 
 
 
 
 








































